import ajax from "@/lib/ajax";
import config from "@/config";

const HOST = config.host("/api", "/gateway");

// 获取列表
const getTaskList = (param) => {
  return ajax.post(`${HOST}/task/list`, param);
};

// 新增数据
const updateTask = (param) => {
  return ajax.post(`${HOST}/task/add`, param);
};

// 新增数据(new)
const createTask = (param) => {
  return ajax.post(`${HOST}/task/create`, param);
};

// 数据详情
const detailTask = (param) => {
  return ajax.get(`${HOST}/task/detail?id=${param.id}`);
};

// 子数据列表
const getKidTask = (param) => {
  return ajax.post(`${HOST}/task/kid/list`, param);
};

// 子数据详情
const detailKidTask = (param) => {
  return ajax.get(`${HOST}/task/kid/detail?id=${param.id}`);
};

// 下载文件
const downloadDemoFile = (param) => {
  return `${HOST}/demo/download?path=${encodeURIComponent(param)}`;
};

export {
  getTaskList,
  createTask,
  updateTask,
  downloadDemoFile,
  detailTask,
  getKidTask,
  detailKidTask,
};
